﻿@using MiddleMVCTask.HtmlHelpers;

@{
    ViewBag.Title = "Home Page";
}

@Html.WelcomeHelper(User.Identity.Name)

<h1>How old are you ? </h1>
<div>

    <input type="text" id="age" />
    <button id="age-submitter">Submit</button>
    <h1>JUST  Littel change 32  32424 </h1>
</div>

@section scripts {
    <script>
        $(function () {
            $("#age-submitter").click(function () {
                var age = $("#age").val();
        
                var data = {
                    age:age
                }
        
                $.ajax({
                           url: "http://localhost:3986/Home/SubmitData",
                           type: "post",
                           contentType: "application/json",
                           data: JSON.stringify(data),
                           success: function (result) {
                               $(".body-content").append("<h2>" + result.text + "</h2>")
                           },
        
                           error: function (error) {
                               console.log(error.statusText)
                           }
                       })
            });
        });
    </script>
}

